<template>
	<view class="content">
		<view class="coupon-list-n">
			<view class="coupon" v-for="(item,index) in goodsList" :key="index">
				<view class="coupon-img">
					<img :src="item.picture" alt="">
				</view>
				<view class="coupon-right">
					<view class="coupon-center">
						<view class="c-title">{{item.name}}</view>
						<view class="c-sub"><img :src="item.nationalFlag" alt="">{{item.originCountry}}</view>
						<view class="c-time">{{item.time}}</view>
					</view>
					<view class="c-integral">-{{item.integral}}</view>
				</view>
			</view>
			<!--<view class="coupon">-->
				<!--<view class="coupon-img">-->
					<!--<img src="/static/index/pic1@2x.png" alt="">-->
				<!--</view>-->
				<!--<view class="coupon-right">-->
					<!--<view class="coupon-center">-->
						<!--<view class="c-title">BIO ISLAND 佰澳郎德 婴幼...</view>-->
						<!--<view class="c-sub"><img src="/static/index/meiguo2@2x.png" alt="">墨西哥牛油果</view>-->
						<!--<view class="c-time">2019.06.15-2019.06.18</view>-->
					<!--</view>-->
					<!--<view class="c-integral">-12</view>-->
				<!--</view>-->
			<!--</view>-->
			<!--<view class="coupon">-->
				<!--<view class="coupon-img">-->
					<!--<img src="/static/index/pic1@2x.png" alt="">-->
				<!--</view>-->
				<!--<view class="coupon-right">-->
					<!--<view class="coupon-center">-->
						<!--<view class="c-title">BIO ISLAND 佰澳郎德 婴幼...</view>-->
						<!--<view class="c-sub"><img src="/static/index/meiguo2@2x.png" alt="">墨西哥牛油果</view>-->
						<!--<view class="c-time">2019.06.15-2019.06.18</view>-->
					<!--</view>-->
					<!--<view class="c-integral">-12</view>-->
				<!--</view>-->
			<!--</view>-->
		</view>
	</view>
</template>

<script>
    import {_IntegraltoProc} from '../../common/vmeitime-http/mem.js'
    import utils from '../../common/utils/util.js'
	export default {
		data() {
			return {
				headerPosition:"fixed",
				headerTop:"0px",
				loadingType: 'more', //加载更多状态
				filterIndex: 0, 
				cateId: 0, //已选三级分类id
				priceOrder: 0, //1 价格从低到高 2价格从高到低
				cateList: [],
				goodsList: []
			};
		},
		
		onLoad(options){
			// #ifdef H5
			this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight+'px';
			// #endif
			this.cateId = options.tid;
			
			
			// ---接口函数----
            // this.loadData({pageNum:"1",pageSize:"8"});
		},
		onPageScroll(e){
			//兼容iOS端下拉时顶部漂移
			if(e.scrollTop>=0){
				this.headerPosition = "fixed";
			}else{
				this.headerPosition = "absolute";
			}
		},
		//下拉刷新
		onPullDownRefresh(){
			// this.loadData('refresh');
		},
		//加载更多
		onReachBottom(){
			// this.loadData();
		},
		methods: {
			//加载商品 ，带下拉刷新和上滑加载
			async loadData(para) {
                let tempData = await _IntegraltoProc(para);
                this.goodsList = tempData.data.data;
                this.goodsList.forEach((item=>{
                    item.time = utils.formatDate.format(new Date(item.createTime),'yyyy.MM.dd hh:mm')
				}))
				// //没有更多直接返回
				// if(type === 'add'){
				// 	if(this.loadingType === 'nomore'){
				// 		return;
				// 	}
				// 	this.loadingType = 'loading';
				// }else{
				// 	this.loadingType = 'more'
				// }
				//
				// let goodsList = await this.$api.json('goodsList');
				// if(type === 'refresh'){
				// 	this.goodsList = [];
				// }
				//
				// this.goodsList = this.goodsList.concat(goodsList);
				//
				// //判断是否还有下一页，有是more  没有是nomore(测试数据判断大于20就没有了)
				// this.loadingType  = this.goodsList.length > 20 ? 'nomore' : 'more';
				// if(type === 'refresh'){
				// 	if(loading == 1){
				// 		uni.hideLoading()
				// 	}else{
				// 		uni.stopPullDownRefresh();
				// 	}
				// }
			},
			//详情
			navToDetailPage(item){
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}`
				})
			},
			stopPrevent(){}
		},
	}
</script>

<style lang="scss">
	page, .content{
		background: $page-color-base;
	}
	.content{
		/*padding-top: 96upx;*/
	}
	/*优惠券列表*/
	.coupon-list-n{
		/*padding: 40rpx;*/
	}
	.coupon{
		padding: 40upx 40upx 0 40upx;
		display: flex;
		background: #ffffff;
		border-radius: 5upx;
		.coupon-img{
			width: 145upx;
			height: 146upx;
			img{
				width: 100%;
				height: 100%;
			}
		}
		.coupon-right{
			font-size: 24upx;
			color: #989898;
			display: flex;
			line-height: 47rpx;
			padding-left: 20upx;
			flex: 1;
			border-bottom: 2upx solid #f2f2f2;
			padding-bottom: 50upx;
			.coupon-center{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: center;
				.c-title{
					font-size: 30upx;
					color: $font-color-dark;
				}
				.c-sub{
					font-size: 24upx;
					color: #656565;
					img{
						width: 23upx;
						height: 23upx;
						margin-right: 14upx;
						border-radius: 50%;
					}
				}
			}
			.c-integral{
				display:flex ;
				font-size: 36upx;
				font-weight: bold;
				align-items: center;
				color: $uni-color-primary;
			}

		}

	}
</style>
